import request from '@/utils/request'
import {encodeParams} from '@/utils'

//树形列表
export function getPageList(data) {
  return request({
    url: '/api/salesParam?${encodeParams(data)}',
    method: 'POST',
    data
  })
}
//一级属性列表
export function getLevel1List(data) {
  return request({
    url: '/api/salesParam/list',
    method: 'POST',
    data
  })
}

//创建
export function create(data) {
  return request({
    url: '/api/salesParam/create',
    method: 'POST',
    data
  })
}

export function findByLevelAndId(level,id){
  return request({
    url: `/api/salesParam/findByLevelAndId/${level}/${id}`,
    method: 'GET',
  })
}
//根据一级属性查询下面二级属性
export function getNextLevelAttrList(salesParamId){
  return request({
    url: `/api/salesParam/getParamValuesByParamId/${salesParamId}`,
    method: 'GET',
  })
}

//根据id删除
export function changeEnable(level,id,enable) {
  return request({
    url: `/api/salesParam/enable/${level}/${id}/${enable}`,
    method: 'GET',
  })
}

//更新
export function update(data) {
  return request({
    url: '/api/salesParam/update',
    method: 'POST',
    data
  })
}

//getAttrlist
export function getList(data={
  "enable": 1,
}) {
  return request({
    url: '/api/salesParam/list',
    method: 'POST',
    data
  })
}



export default {
  getPageList,getLevel1List,create, findByLevelAndId, update, changeEnable,getList,getNextLevelAttrList
}
